<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容" class="input-with-select">
            <el-button slot="append" icon="el-icon-search" class="btn"></el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
          <el-button type="primary" icon="el-icon-search"></el-button>
        </el-col>
      </el-row>
      <el-table :data="getOrderList" style="width: 100%" border stript>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="user_id" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"></el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.pay_status == '1'">已付款</el-tag>
            <el-tag type="danger" v-else>未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="name" label="发货时间">
          <template slot-scope="scope">{{scope.row.create_time | datematfor}}</template>
        </el-table-column>
        <el-table-column prop="name" label="操作" width="180">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" icon="el-icon-edit" @click="ShowOrderDialog">编辑</el-button>
            <el-button
              size="mini"
              type="success"
              icon="el-icon-location"
              @click="showporpessDialog"
            >位置</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryData.pagenum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="queryData.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
    <el-dialog title="修改地址" :visible.sync="addOrderDialogVisible" width="50%">
      <el-cascader v-model="orderList" :options="cityData" :props="props"></el-cascader>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addOrderDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="showOrderList">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 快递位置对话框 -->
    <el-dialog title="抵达地址" :visible.sync="dropressDialogVisible" width="50%">
      <el-timeline :reverse="reverse">
        <el-timeline-item
          v-for="(activity, index) in logisticsList"
          :key="index"
          :timestamp="activity.time"
        >{{activity.context}}</el-timeline-item>
      </el-timeline>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dropressDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dropressDialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import cityData from "./citydata";
export default {
  data() {
    return {
      queryData: {
        query: "",
        pagesize: 10,
        pagenum: 1
      },
      reverse:false,
      total: 0,
      orderList: [],
      cityData,
      props: {
        expandTrigger: "hover",
        lable: "lable",
        value: "value"
      },
      addOrderDialogVisible: false,
      dropressDialogVisible: false,
      getOrderList: [],
      logisticsList: []
    };
  },

  methods: {
    async getOrder() {
      const res = await this.axios.get("orders/", {
        params: this.queryData
      });
      if (res.meta.status !== 200) return this.$mg.error(res.meta.msg);
      this.getOrderList = res.data.goods;
      this.total = res.data.total;
      console.log(this.getOrderList);
    },
    handleSizeChange(val) {
      this.queryData.pagesize = val;
      this.getOrder();
    },
    handleCurrentChange(val) {
      this.queryData.pagenum = val;
      this.getOrder();
    },
    ShowOrderDialog() {
      this.addOrderDialogVisible = true;
    },
    showOrderList() {
      console.log(this.orderList);
    },
    async showporpessDialog() {
      this.dropressDialogVisible = true;
      const res = await this.axios.get("/kuaidi/1106975712662");
      if (res.meta.status !== 200) return;
      this.logisticsList = res.data;
    }
  },

  created() {
    this.getOrder();
  }
};
</script>

<style lang='less' scoped>
</style>
